﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbBlockElement : OdDbEvalConnectable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbBlockElement(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbBlockElement_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbBlockElement obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbBlockElement()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbBlockElement(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbBlockElement cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbBlockElement_cast(OdRxObject.getCPtr(pObj));
			OdDbBlockElement result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbBlockElement)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbBlockElement)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbBlockElement)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbBlockElement_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbBlockElement_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbBlockElement_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbBlockElement createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbBlockElement_createObject();
			OdDbBlockElement result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbBlockElement)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbBlockElement)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbBlockElement)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdResult dwgInFields(OdDbDwgFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbBlockElement_dwgInFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dwgOutFields(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdDbBlockElement_dwgOutFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdResult dxfInFields(OdDbDxfFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbBlockElement_dxfInFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dxfOutFields(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdDbBlockElement_dxfOutFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool evaluate(OdDbEvalContext arg0)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_evaluate(this.swigCPtr, OdDbEvalContext.getCPtr(arg0));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool connectionAllowed(string arg0, uint arg1, string arg2)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_connectionAllowed(this.swigCPtr, arg0, arg1, arg2);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool connectTo(string arg0, uint arg1, string arg2)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_connectTo(this.swigCPtr, arg0, arg1, arg2);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool disconnectFrom(string arg0, uint arg1, string arg2)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_disconnectFrom(this.swigCPtr, arg0, arg1, arg2);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool hasConnectionNamed(string arg0)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_hasConnectionNamed(this.swigCPtr, arg0);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool getConnectedNames(string arg0, uint arg1, OdStringArray arg2)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_getConnectedNames(this.swigCPtr, arg0, arg1, OdStringArray.getCPtr(arg2));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool getConnectedObjects(string arg0, OdDbEvalNodeIdArray arg1)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_getConnectedObjects(this.swigCPtr, arg0, OdDbEvalNodeIdArray.getCPtr(arg1));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void getConnectionNames(OdStringArray arg0)
		{
			TD_DbPINVOKE.OdDbBlockElement_getConnectionNames(this.swigCPtr, OdStringArray.getCPtr(arg0));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool getConnectionType(string name, SWIGTYPE_p_OdResBuf__ValueType type)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_getConnectionType(this.swigCPtr, name, SWIGTYPE_p_OdResBuf__ValueType.getCPtr(type));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdResBuf getConnectionValue(string name)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbBlockElement_getConnectionValue(this.swigCPtr, name);
			OdResBuf result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual string name()
		{
			string result = TD_DbPINVOKE.OdDbBlockElement_name(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setName(string arg0)
		{
			TD_DbPINVOKE.OdDbBlockElement_setName(this.swigCPtr, arg0);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual MaintReleaseVer getInstanceMaintenanceVersion()
		{
			MaintReleaseVer result = (MaintReleaseVer)TD_DbPINVOKE.OdDbBlockElement_getInstanceMaintenanceVersion(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual DwgVersion getInstanceVersion()
		{
			DwgVersion result = (DwgVersion)TD_DbPINVOKE.OdDbBlockElement_getInstanceVersion(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getStretchPoints(OdGePoint3dArray arg0)
		{
			TD_DbPINVOKE.OdDbBlockElement_getStretchPoints(this.swigCPtr, OdGePoint3dArray.getCPtr(arg0));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void moveStretchPointsAt(OdIntArray arg0, OdGeVector3d arg1)
		{
			TD_DbPINVOKE.OdDbBlockElement_moveStretchPointsAt(this.swigCPtr, OdIntArray.getCPtr(arg0).Handle, OdGeVector3d.getCPtr(arg1));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdDbBlockElement.HistoryCompression historyCompression()
		{
			OdDbBlockElement.HistoryCompression result = (OdDbBlockElement.HistoryCompression)TD_DbPINVOKE.OdDbBlockElement_historyCompression(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool historyRequired()
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_historyRequired(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool hasInstanceData()
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_hasInstanceData(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool loadInstanceData(OdResBuf arg0)
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_loadInstanceData(this.swigCPtr, OdResBuf.getCPtr(arg0));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResBuf saveInstanceData()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbBlockElement_saveInstanceData(this.swigCPtr);
			OdResBuf result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void updateConnections()
		{
			TD_DbPINVOKE.OdDbBlockElement_updateConnections(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isMemberOfCurrentVisibilitySet()
		{
			bool result = TD_DbPINVOKE.OdDbBlockElement_isMemberOfCurrentVisibilitySet(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setMemberOfCurrentVisibilitySet(bool arg0)
		{
			TD_DbPINVOKE.OdDbBlockElement_setMemberOfCurrentVisibilitySet(this.swigCPtr, arg0);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult transformBy(OdGeMatrix3d arg0)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbBlockElement_transformBy(this.swigCPtr, OdGeMatrix3d.getCPtr(arg0));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum HistoryCompression
		{
			kHistoryCompression0,
			kHistoryCompression1,
			kHistoryCompression2,
			kHistoryCompression3
		}
	}
}
